package com.scalar.chiptrack.operations.dataentry.lotcorrection.actions;

import com.scalar.chiptrack.ChipTrackAction;
import com.scalar.chiptrack.commons.SessionKeys;
import com.scalar.chiptrack.operations.dataentry.lotcorrection.actionCommands.LotCorrectionActionCommandFactory;
import com.scalar.chiptrack.actioncommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * User: Ganesh
 * Date: Nov 28, 2006
 * Time: 11:29:09 AM
 */
public class LotCorrectionAction extends ChipTrackAction implements SessionKeys
{
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        HashMap errors = new HashMap();
        HashMap info   = new HashMap();

        request.setAttribute(INFO_MESSAGES, info);
        request.setAttribute(ERROR_MESSAGES, errors);

        ActionForward actionForward;
        String action = request.getParameter("action");
        try
        {
            ActionCommand lotCorrectionCommand;
            lotCorrectionCommand = LotCorrectionActionCommandFactory.getActionCommand( action );
            actionForward   = lotCorrectionCommand.execute( mapping, form, request, response );
        }
        catch (Exception e)
        {
            errors.put("Unable to load the Processes for Lot Correction ", null);
            actionForward = mapping.findForward("lotCorrection");
        }
        return actionForward;
    }

}

